package summary;

/**
 * @Author: 海琳琦
 * @Date: 2022/8/17 15:17
 */
public class Title165 {

    public int compareVersion(String version1, String version2) {
        String[] split = version1.split("\\.");
        String[] split1 = version2.split("\\.");
        int lenA = split.length;
        int lenB = split1.length;
        int max = Math.max(lenA, lenB);
        for (int i = 0; i < max; i++) {
            int a = i < lenA ? Integer.valueOf(split[i]) : 0;
            int b = i < lenB ? Integer.valueOf(split1[i]) : 0;
            if (a > b) {
                return 1;
            } else if (a < b) {
                return -1;
            }
        }
        return 0;
    }

    public static void main(String[] args) {


    }
}
